package t211119;

/**
 * @Author: DengJia
 * @Date: 2021/11/19 20:45
 * @Description:
 */

public class Main {
    public static void main(String[] args) {
        Cycle
                c1 = new Unicycle(),
                c2 = new Bicycle(),
                c3 = new Tricycle();

        c1.ride();
        c2.ride();
        c3.ride();

        Rodent rodent = new Mouse();
        rodent.m1();
    }
}

class Cycle {
    public void ride() {
        System.out.println("ride -> Cycle, wheels:" + wheels());
    }

    public int wheels() {
        return 0;
    }
}

class Unicycle extends Cycle {
    @Override
    public void ride() {
        System.out.println("ride -> Unicycle, wheels:" + wheels());
    }

    @Override
    public int wheels() {
        return 1;
    }
}

class Bicycle extends Cycle {
    @Override
    public void ride() {
        System.out.println("ride -> Bicycle, wheels:" + wheels());
    }

    @Override
    public int wheels() {
        return 2;
    }
}

class Tricycle extends Cycle {
    @Override
    public void ride() {
        System.out.println("ride -> Tricycle, wheels:" + wheels());
    }

    @Override
    public int wheels() {
        return 3;
    }
}

class Rodent {
    public void m1() {
        System.out.println("基类方法1");
        m2();
    }

    public void m2() {
        System.out.println("基类方法2");
    }
}

class Mouse extends Rodent {
    @Override
    public void m2() {
        System.out.println("导出类方法2");
    }
}
